#ifndef _COMMAND_HPP_
#define _COMMAND_HPP_

#include <iostream>
#include <string>
#include <cerrno>
#include <cstring>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

using namespace std;


#define Mode 0666
#define Path "./Fifo"

class Fifo
{
    public:
    
    Fifo(const string& path)
    :_path(path)
    {
        umask(0);
        int n = mkfifo(path.c_str(),Mode);
        if(n==0)
        {
            cout<<"mkfifo success"<<endl;
        }
        else
        {
            cerr<<"mkfifo error: "<<errno<<",errstring: "<<strerror(errno)<<endl;
        }

    }

    ~Fifo()
    {
        int n = unlink(_path.c_str());
        if(n==0)
        {
            cout<<"unlink success"<<endl;
        }
        else
        {
            cerr<<"unlink error: "<<errno<<",errstring: "<<strerror(errno)<<endl;
        }
    }

    private:
    string _path;
};

#endif